package com.woniuxy01;

import java.util.Scanner;

/**
 * @author 作者
 * @create 2025-07-16 9:36
 */
public class Test02 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("输入运算数");
        int numA = sc.nextInt();
        System.out.println("输入运算数");
        int numB = sc.nextInt();
        System.out.println("输入运算符+-*/");
        char opeartor= sc.next().charAt(0);
        int result=0;
        //operatorFlag---true运算符有效
        boolean operatorFlag=true;
        //divideFlag---true除数不为0，可以进行除法运算
        boolean divideFlag=true;
        if(opeartor=='+'){
            result = numA+numB;
        }else if(opeartor=='-'){
            result = numA-numB;
        }else if(opeartor=='*'){
            result = numA*numB;
        }else if(opeartor=='/'){
            if (numB!=0) {
                result = numA/numB;
            }else{
                divideFlag=false;
            }
        }else{
            operatorFlag=false;
        }
        //统一输出
        if(operatorFlag){
            if(!divideFlag){
                System.out.println("除数不能为0");
            }else{
                System.out.println("运算结果是："+numA+opeartor+numB+"="+result);
            }
        }else{
            System.out.println("无效运算符，无法计算");
        }
    }
}
